import {defineStore} from 'pinia'

export const useUserLoginStore = defineStore('userLogin', {

    state: () => {
        return {
            account: '--',
            isLogin: false,
            jToken: '',
        }
    },
    getters: {

        getAccount: (state) => {
            return state.account;
        },

        getIsLogin: (state) => {
            return state.isLogin;
        },

        getJToken: (state) => {
            return state.jToken;
        },

    },

    actions: {

        setAccount(value) {
            this.account = value;
        },

        setIsLogin(value) {
            this.isLogin = value;
        },

        setJToken(value) {
            this.jToken = value;
        },

        setAll(account, isLogin, jToken) {
            this.account = account;
            this.isLogin = isLogin;
            this.jToken = jToken;
        },

        reset() {
            this.account = '--';
            this.isLogin = false;
            this.jToken = '';
        }

    },

    persist: {
        storage: sessionStorage,
    },
})